package com.his.service.impl;

import com.his.entity.NursingCategory;
import com.his.mapper.NursingCategoryMapper;
import com.his.service.NursingCategoryService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (NursingCategory)表服务实现类
 *
 * @author makejava
 * @since 2020-10-23 18:13:37
 */
@Service("nursingCategoryService")
public class NursingCategoryServiceImpl implements NursingCategoryService {
    @Resource
    private NursingCategoryMapper nursingCategoryMapper;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public NursingCategory queryById(Integer id) {
        return this.nursingCategoryMapper.queryById(id);
    }

    /**
     * 查询所有通过实体类属性
     *
     * @param nursingCategory 实例对象
     * @return 查询的结果
     */
    @Override
    public List<NursingCategory> queryAll(NursingCategory nursingCategory) {
        return this.nursingCategoryMapper.queryAll(nursingCategory);
    }

    /**
     * 新增数据
     *
     * @param nursingCategory 实例对象
     * @return 实例对象
     */
    @Override
    public NursingCategory insert(NursingCategory nursingCategory) {
        this.nursingCategoryMapper.insert(nursingCategory);
        return nursingCategory;
    }

    /**
     * 修改数据
     *
     * @param nursingCategory 实例对象
     * @return 实例对象
     */
    @Override
    public NursingCategory update(NursingCategory nursingCategory) {
        this.nursingCategoryMapper.update(nursingCategory);
        return this.queryById(nursingCategory.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer id) {
        return this.nursingCategoryMapper.deleteById(id) > 0;
    }
}